package com.webtest.shoppingcar1;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/8/7 22:37
 */
public class ProcessStep2Servlet extends HttpServlet {
    private static final long serialVersionUID = -692848753225209177L;

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.获取请求参数：name,address,cardType,cardNo
        String name = req.getParameter("name");
        String address = req.getParameter("address");
        String cardType = req.getParameter("cardType");
        String cardNo = req.getParameter("cardNo");
        //2.把请求参数放入到HttpSession中
        Customer customer = new Customer(name, address, cardType, cardNo);
        HttpSession session = req.getSession();
        session.setAttribute("customer", customer);
        //3.重定向到页面confirm.jsp中
        resp.sendRedirect(req.getContextPath() + "/shoppingcart/confirm.jsp");
    }
}
